namespace SageKing.Database.EF.Contracts;

/// <summary>
/// 框架实体基类Id
/// </summary>
public abstract class EntityBaseId<T> : Cloneable, IEntityBaseId<T>
{
    public virtual T Id { get; set; }
}

/// <summary>
/// 框架实体基类
/// </summary> 
public abstract class EntityBase<T> : EntityBaseId<T>, IEntityBase<T>
{
    /// <summary>
    /// 创建时间
    /// </summary>
    public virtual DateTime CreateTime { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public virtual DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 创建者Id
    /// </summary>
    public virtual long? CreateUserId { get; set; }

    ///// <summary>
    ///// 创建者
    ///// </summary>
    //[Newtonsoft.Json.JsonIgnore]
    //[System.Text.Json.Serialization.JsonIgnore]
    //[Navigate(NavigateType.OneToOne, nameof(CreateUserId))]
    //public virtual SysUser CreateUser { get; set; }

    /// <summary>
    /// 创建者姓名
    /// </summary>
    public virtual string? CreateUserName { get; set; }

    /// <summary>
    /// 修改者Id
    /// </summary>
    public virtual long? UpdateUserId { get; set; }

    ///// <summary>
    ///// 修改者
    ///// </summary>
    //[Newtonsoft.Json.JsonIgnore]
    //[System.Text.Json.Serialization.JsonIgnore]
    //[Navigate(NavigateType.OneToOne, nameof(UpdateUserId))]
    //public virtual SysUser UpdateUser { get; set; }

    /// <summary>
    /// 修改者姓名
    /// </summary>
    public virtual string? UpdateUserName { get; set; }

    /// <summary>
    /// 软删除
    /// </summary>
    public virtual bool IsDelete { get; set; } = false;
}

/// <summary>
/// 业务数据实体基类（数据权限）
/// </summary>
public abstract class EntityBaseData<T, Tt> : EntityBase<T>, IEntityBaseData<T, Tt>, IOrgIdFilter<Tt>
{
    /// <summary>
    /// 创建者部门Id
    /// </summary>
    public virtual Tt? CreateOrgId { get; set; }

    ///// <summary>
    ///// 创建者部门
    ///// </summary>
    //[Newtonsoft.Json.JsonIgnore]
    //[System.Text.Json.Serialization.JsonIgnore]
    //[Navigate(NavigateType.OneToOne, nameof(CreateOrgId))]
    //public virtual SysOrg CreateOrg { get; set; }

    /// <summary>
    /// 创建者部门名称
    /// </summary>
    public virtual string? CreateOrgName { get; set; }
}

/// <summary>
/// 租户实体基类
/// </summary>
public abstract class EntityTenant<T, Tt> : EntityBase<T>, IEntityTenant<T, Tt>, ITenantIdFilter<Tt>
{
    /// <summary>
    /// 租户Id
    /// </summary>
    public virtual Tt? TenantId { get; set; }
}

/// <summary>
/// 租户实体基类Id
/// </summary>
public abstract class EntityTenantId<T, Tt> : EntityBaseId<T>, IEntityTenantId<T, Tt>, ITenantIdFilter<Tt>
{
    /// <summary>
    /// 租户Id
    /// </summary>
    public virtual Tt? TenantId { get; set; }
}

/// <summary>
/// 租户实体基类 + 业务数据（数据权限）
/// </summary>
public abstract class EntityTenantBaseData<T, Tt> : EntityBaseData<T, Tt>, IEntityTenantBaseData<T, Tt>, ITenantIdFilter<Tt>
{
    /// <summary>
    /// 租户Id
    /// </summary>
    public virtual Tt? TenantId { get; set; }
}